package com.example.gty.controller;

import com.example.gty.entity.StudentVo;
import com.example.gty.service.StudentService;
import com.example.gty.utils.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/student")
@Api(tags = "学生成绩信息管理")
public class StudentController {
    @Autowired
    private StudentService studentService;


    @RequestMapping(value = "/selectStuGradeBySno",method = RequestMethod.GET)
    @ApiOperation("按学号查询单个学生成绩信息")
    public List<StudentVo> selectStuGradeBySno(String sno){
        return studentService.selectStuGradeBySno(sno);
    }

    @RequestMapping(value = "/selectAllGrade",method = RequestMethod.GET)
    @ApiOperation("查询所有学生 所有成绩")
    public ResultVo selectAllGrade(String sno){
        return studentService.selectStuAllGrade(sno);
    }

    @RequestMapping(value = "/selectStuMulti",method = RequestMethod.GET)
    @ApiOperation("多条件查询学生成绩 性别 班级 专业 学院")
    public ResultVo se(String sex, String cclass, String major, String college){
        return studentService.selectStuMulti(sex, cclass, major, college);
    }

    @ApiOperation("单科目 修改学生成绩信息")
    @RequestMapping(value = "/updateStuGrade",method = RequestMethod.GET)
    public ResultVo updateStuGrade(String sno, String cno, Integer score){
        return studentService.updateStuGrade(sno, cno, score);
    }

    @ApiOperation("删除学生")
    @RequestMapping(value = "/deleteStu",method = RequestMethod.DELETE)
    public ResultVo deleteStu(String sno){
        return studentService.deleteStu(sno);
    }

    @ApiOperation("按照班级学生成绩柱状图分析")
    @RequestMapping(value = "/columnChart",method = RequestMethod.GET)
    public ResultVo columnChart(String cclass){
        ResultVo resultVo = studentService.selectStuMulti(null, cclass, null, null);
        return resultVo;
    }

    @ApiOperation("查询所有班级")
    @RequestMapping(value = "/selectCclass",method = RequestMethod.GET)
    public ResultVo selectCclass(){
        return studentService.selectCclass();
    }

}
